<template>
  <el-dialog title="会员编辑" 
  :visible.sync="dialist.isShow" 
  center 
  :before-close="cancle">
  <el-form :model="list" ref="diaform" :rules="rules">
    <el-form-item label="手机号" :label-width="formLabelWidth" prop="phone">
      <el-input v-model="list.phone" autocomplete="off" disabled></el-input>
    </el-form-item>
    <el-form-item label="昵称" :label-width="formLabelWidth" prop="nickname">
      <el-input v-model="list.nickname" autocomplete="off" disabled></el-input>
    </el-form-item>
    <el-form-item label="密码" :label-width="formLabelWidth">
      <el-input v-model="list.password" autocomplete="off"></el-input>
      <span>密码留空就不修改</span>
    </el-form-item>
   
     <el-form-item label="状态" :label-width="formLabelWidth">
      <el-switch v-model="list.status" :active-value="1" :inactive-value="2"></el-switch>
    </el-form-item>
  </el-form>
  <div slot="footer" class="dialog-footer">
    <el-button @click="cancle">取 消</el-button>
    <el-button type="primary" @click="edit">编 辑</el-button>
  </div>
</el-dialog>
</template>
<script>
import {getMemberOne,editMember} from "../../util/axios"
import {mapActions} from "vuex"
export default {
 data(){
     return{
         list:{
             nickname:"",
             phone:"",
             password:"",
             status:1
         },
         formLabelWidth:"120px",
         rules:{
            phone:[
              { required: true, message: "请输入手机号", trigger: "blur" },
            ],
            nickname:[
               { required: true, message: "请输入昵称 ", trigger: "blur" },
            ]

         }
     }
 },
 props:["dialist"],
 methods:{
     cancle(){
         this.list={
             nickname:"",
             phone:"",
             password:"",
             status:1
         },
         this.$emit("cancle",false);

     },
     ...mapActions({
        getMemberLists:"member/memberlistAction"
      }),
     edit(){
       editMember(this.list).then(res=>{
          if(res.code == 200){
              this.getMemberLists();
              this.cancle();
          }else{
            this.$message.error(res.msg)
          }
       })
     }, 
     lookup(uid){
      //  console.log(id);
         getMemberOne({uid}).then(res=>{
             if(res.code == 200){
               this.list =res.list;
               this.list.uid = uid;
               this.list.password = "";
             }else{
                 this.$message.error(res.msg)
             }
         })
     }
 }
}
</script>

<style>

</style>